﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace PokemonBattle.PokemonData
{
    public class Base6D : IEnumerable<int>
    {

        #region props

        private int[] values;
        public int this[int i]
        {
            get { return values[i]; }
            set
            {
                if (i > 0 && i < values.Length)
                {
                    values[i] = value;
                }
            }
        }
        public int Hp
        {
            get { return values[0]; }
            set { values[0] = value; }
        }
        public int Atk
        {
            get { return values[1]; }
            set { values[1] = value; }
        }
        public int Def
        {
            get { return values[2]; }
            set { values[2] = value; }
        }
        public int Speed
        {
            get { return values[3]; }
            set { values[3] = value; }
        }
        public int SpAtk
        {
            get { return values[4]; }
            set { values[4] = value; }
        }
        public int SpDef
        {
            get { return values[5]; }
            set { values[5] = value; }
        }

        #endregion

        #region fun

        public Base6D() : this(0) { }

        public Base6D(int value)
        {
            values = Enumerable.Repeat<int>(value, 6).ToArray();
        }

        public Base6D(Base6D b6d)
        {
            for (int i = 0; i < values.Length; i++)
            {
                values[i] = b6d[i];
            }
        }

        public void SetAll(int value)
        {
            for (int i = 0; i < values.Length; i++)
            {
                values[i] = value;
            }
        }

        #endregion

        #region IEnumerable<int>

        #region IEnumerator

        public IEnumerator<int> GetEnumerator()
        {
            foreach (int value in values)
            {
                yield return value;
            }
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return this.values.GetEnumerator();
        }

        #endregion

        #endregion
    }
}